package com.charonmc.commands;

import com.charonmc.utils.BungeeCordChatUtils;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;

public class BuilderChat extends Command {
    public BuilderChat() {
        super("BuilderChat","Core.BuilderChat","bc");
    }

    public void execute(CommandSender sender, String[] args) {
        if (args.length < 1) {
            sender.sendMessage("参数错误！");
        }
        else {
            StringBuilder msg = new StringBuilder();
            for (String arg : args) {
                if (msg.toString().equals("")) {
                    msg = new StringBuilder(arg);
                } else {
                    msg.append(" ").append(arg);
                }
            }
            if (sender instanceof ProxiedPlayer) {
                ProxiedPlayer player = (ProxiedPlayer) sender;
                BungeeCordChatUtils.sendBCMessage(player, msg.toString());
            }
            else {
                BungeeCordChatUtils.sendBCMessage(msg.toString());
            }
        }
    }
}
